package com.by.utils;

import java.util.Map;

public class ThreadLocalUtils {

    static ThreadLocalUtils instance;
    /**
     * 线程局部变量
     */
    ThreadLocal<Map> threadLocal = new ThreadLocal<>();

    /**
     * 保存数据
     * @param map
     */
    public  void set(Map map) {
        threadLocal.set(map);
    }
    public Map get() {
        return threadLocal.get();
    }
    public void remove() {
        threadLocal.remove();
    }

    private ThreadLocalUtils() {
    }


    public static ThreadLocalUtils getInstance() {
        if (instance == null) {
            instance = new ThreadLocalUtils();
        }
        return instance;
    }

}
